﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using _1242026_1242133.DTO;
namespace _1242026_1242133.DAO
{
    class PhongDAO
    {   
        
        public DataTable ThemPhong(PhongDTO PhongDTO)
        {
            SqlSever SQL = new SqlSever();
            SqlParameter[] arrParam = {   new SqlParameter("@MaPhong", SqlDbType.VarChar), 
                                          new SqlParameter("@TenPhong", SqlDbType.VarChar),
                                          new SqlParameter("@GhiChu", SqlDbType.VarChar),           
                                          new SqlParameter("@MaLoaiPhong", SqlDbType.Text)
                                      };
            arrParam[0].Value = PhongDTO.MaPhong;
            arrParam[1].Value = PhongDTO.TenPhong;
            arrParam[2].Value = PhongDTO.GhiChu;
            arrParam[3].Value = PhongDTO.MaLoaiPhong;
            DataTable data = SQL.ExecuteStore("sp_ThemPhong", arrParam);
            return data;
        }
        public DataTable SuaPhong(PhongDTO PhongDTO)
        {
            SqlSever SQL = new SqlSever();
            SqlParameter[] arrParam = {   new SqlParameter("@MaPhong", SqlDbType.VarChar), 
                                          new SqlParameter("@TenPhong", SqlDbType.VarChar),
                                          new SqlParameter("@GhiChu", SqlDbType.VarChar),           
                                          new SqlParameter("@MaLoaiPhong", SqlDbType.Text)
                                      };
            arrParam[0].Value = PhongDTO.MaPhong;
            arrParam[1].Value = PhongDTO.TenPhong;
            arrParam[2].Value = PhongDTO.GhiChu;
            arrParam[3].Value = PhongDTO.MaLoaiPhong;
            DataTable data = SQL.ExecuteStore("sp_SuaPhong", arrParam);
            return data;
        }
        //public DataTable UpdateTinhTrangPhong(string MaPhong)
        //{
        //    SqlSever SQL = new SqlSever();
        //    SqlParameter[] arrParam = { new SqlParameter("@MaPhong", SqlDbType.VarChar) };
        //    arrParam[0].Value = MaPhong;
        //    return SQL.ExecuteStore();
        //}

        public DataTable XoaPhong(PhongDTO PhongDTO)
        { 
            SqlSever SQL = new SqlSever();
            SqlParameter[]arrParam = {new SqlParameter("@MaPhong",SqlDbType.VarChar)};
            arrParam[0].Value = PhongDTO.MaPhong;
            return SQL.ExecuteStore("sp_XoaPhong",arrParam);
        }
        public DataTable LoadDanhSachPhong()
        {
            SqlSever SQL = new SqlSever();
            return SQL.ExecuteCommandText("Select Phong.MaPhong,Phong.MaLoaiPhong,Phong.TenPhong, Phong.TinhTrangPhong, Phong.GhiChu,LoaiPhong.TenLoaiPhong From Phong,LoaiPhong where Phong.MaLoaiPhong = LoaiPhong.MaLoaiPhong");
        }



    }
}
